package com.jt.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jt.common.exception.ServiceException;
import com.jt.common.vo.PageObject;
import com.jt.sys.dao.SysLogDao;
import com.jt.sys.entity.SysLog;
import com.jt.sys.service.SysLogService;
@Service
public class SysLogServiceImpl implements SysLogService{

	@Autowired
	SysLogDao sysLogDao;
	@Override
	public PageObject<SysLog> findPageObjects(String username, Integer pageCurrent) {
	
		if(pageCurrent==null||pageCurrent<1){
			throw new IllegalArgumentException("输入参数不合法");
		}
		int rowCount=sysLogDao.getRowCount(username);
		if(rowCount==0)throw new ServiceException("无记录");
		int pageSize=3;
		int startIndex=(pageCurrent-1)*pageSize;
		
		List<SysLog> list=sysLogDao.findPageObjects(username, startIndex, pageSize);
		//封装数据
		PageObject<SysLog> pg=new PageObject<>();
		pg.setRecords(list);
		pg.setRowCount(rowCount);
		pg.setPageSize(pageSize);
		pg.setPageCurrent(pageCurrent);
		return pg;
	}

}
